<?php

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use App\Base\Annotation\Common;
use App\Repository\ArticleRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * @ApiResource()
 * @ORM\Entity(repositoryClass=ArticleRepository::class)
 */
class Article
{
    /**
     * @Common(cnName="#",listType="text",editType="text")
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     * @Groups({"art"})
     */
    private $id;

    /**
     * @Common(cnName="标题",listType="text",editType="text",width="")
     * @ORM\Column(type="string", length=255)
     * @Groups({"art"})
     */
    private $title;

    /**
     * @Common(cnName="标题",listType="text",editType="art")
     * @ORM\Column(type="text", nullable=true)
     * @Groups({"art"})
     */
    private $content;

    /**
     * @Common(cnName="分类",listType="text",editType="select",width="150")
     * @ORM\ManyToOne(targetEntity=ComCategory::class)
     * @Groups({"art"})
     */
    private $category;

    /**
     * @Common(cnName="封面",listType="text",editType="pic",width="150")
     * @ORM\Column(type="string", length=255, nullable=true)
     * @Groups({"art"})
     */
    private $pic;

    /**
     * @Common(cnName="相册",listType="text",editType="pics",width="150")
     * @ORM\Column(type="array", nullable=true)
     * @Groups({"art"})
     */
    private $pics = [];

    /**
     * @Common(cnName="发布时间",listType="text",editType="datetime",width="150")
     * @ORM\Column(type="datetime")
     * @Groups({"art"})
     */
    private $createAt;

    /**
     * @Common(cnName="浏览量",listType="text",editType="text",width="100")
     * @ORM\Column(type="string", length=255)
     * @Groups({"art"})
     */
    private $views = 1;

    /**
     * @Common(cnName="是否置顶",listType="text",editType="switch",width="100")
     * @ORM\Column(type="boolean")
     * @Groups({"art"})
     */
    private $isTop = false;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getTitle(): ?string
    {
        return $this->title;
    }

    public function setTitle(string $title): self
    {
        $this->title = $title;

        return $this;
    }

    public function getContent(): ?string
    {
        return $this->content;
    }

    public function setContent(?string $content): self
    {
        $this->content = $content;

        return $this;
    }

    public function getCategory(): ?ComCategory
    {
        return $this->category;
    }

    public function setCategory(?ComCategory $category): self
    {
        $this->category = $category;

        return $this;
    }

    public function getPic(): ?string
    {
        return $this->pic;
    }

    public function setPic(?string $pic): self
    {
        $this->pic = $pic;

        return $this;
    }

    public function getPics(): ?array
    {
        return $this->pics;
    }

    public function setPics(?array $pics): self
    {
        $this->pics = $pics;

        return $this;
    }

    public function getCreateAt(): ?\DateTimeInterface
    {
        return $this->createAt;
    }

    public function setCreateAt(\DateTimeInterface $createAt): self
    {
        $this->createAt = $createAt;

        return $this;
    }

    public function getViews(): ?string
    {
        return $this->views;
    }

    public function setViews(string $views): self
    {
        $this->views = $views;

        return $this;
    }

    public function getIsTop(): ?bool
    {
        return $this->isTop;
    }

    public function setIsTop(bool $isTop): self
    {
        $this->isTop = $isTop;

        return $this;
    }
}
